package com.example.mall.mq;

import com.example.mall.constants.BaseConstants;
import io.netty.util.CharsetUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Component
@RocketMQMessageListener(topic = BaseConstants.PayMQ.TOPIC_PAY_RESULT,
        selectorExpression=BaseConstants.PayMQ.TAGS_BUYCOURSE_RESULT_2COURSE
        ,consumerGroup = "service-course-pay-reslut-consumer"
        ,messageModel = MessageModel.CLUSTERING )
public class BuyProductPayResultMessageConsumer implements RocketMQListener<MessageExt> {


    //商品订单支付结果处理
    @Override
    @Transactional
    public void onMessage(MessageExt message) {
        String msg = new String(message.getBody(), CharsetUtil.UTF_8);
        log.info("课程消费者,处理支付结果收到消息-> {} ",msg);

    }
}
